import React from "react";
import dayjs from "dayjs";
import { Button } from "antd";
import { authButton } from "@/common";


/**@description 列表表格字段 */
const getColumns = ({ open = Function, handleDelete = Function }) => {
    const columns = [
        {
            title: "发布时间",
            key: "createDate",
            dataIndex: "createDate",
            width: 180,
            render: (text) => dayjs(text).format("YYYY-MM-DD HH:mm")
        },
        {
            title: "用户名",
            key: "userName",
            dataIndex: "userName",
            width: 180,
        },
        {
            title: "内容",
            key: "msgContext",
            dataIndex: "msgContext",
        },
        {
            title: "操作",
            key: "action",
            dataIndex: "action",
            width: 180,
            render: (text, record) => {
                return authButton("context:message:list:delete") && <Button type="link" danger onClick={() => handleDelete({ ids: [record._id] })}>删除</Button>
            }
        }
    ];
    return columns;
}

export default getColumns;